

import 'package:favorcate/core/router/unknown.dart';
import 'package:favorcate/ui/pages/filter/filter.dart';
import 'package:favorcate/ui/pages/home/home.dart';
import 'package:favorcate/ui/pages/main/main.dart';
import 'package:favorcate/ui/pages/meal/meal.dart';
import 'package:favorcate/ui/pages/detail/meal_detail.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class JKRouter {

  // 这里面的路由默认是弹出是系统的从右往左
  static final Map<String, WidgetBuilder> routes = {
    JKMainScreen.routeName: (ctx) => JKMainScreen(),
    JKHomeScreen.routeName: (ctx) => JKHomeScreen(),
    JKMealScreen.routeName: (ctx) => JKMealScreen(),
    JKMealDetailScreen.routeName: (ctx) => JKMealDetailScreen(),
  };

  // 首先展示的界面，第一个路由可以是 '/'
  static final String initialRoute = JKMainScreen.routeName;

  // 当routes里面找不到的时候，就会到这里根据名字找到对应的页面
  static final RouteFactory generateRoute = (settings) {
    if (settings.name == JKFilterScreen.routeName) {
      return MaterialPageRoute(
          builder: (ctx) {
            return JKFilterScreen();
          },
          fullscreenDialog: true
      );
    }
    return null;
  };

  // 根据路由找不到界面的时候做展示的错误页面
  static final RouteFactory unknownRoute = (settings) {
    return MaterialPageRoute(
        builder: (ctx) {
          return JKUnknownPage();
        }
    );
  };
}